package cn.hy.concurrent.AQS;


public class Demo01 {
    public static void main(String[] args) throws Exception {
        BoundedBuffer buffer = new BoundedBuffer(2);


        new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                try {
                    buffer.put(i);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

        }).start();

        new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                try {
                    buffer.take();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

        }).start();


    }
}
